﻿@{Layout = null;}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    <link rel="SHORTCUT ICON" href="@Html.BaseUrl()ico.ico" />
    <link rel="shortcut icon" type="image/x-icon" href="@Html.BaseUrl()ico.ico" />
    
    @if (this.Request.QueryString["modern"] == "1")
    {
        @Styles.Render("~/Content/login/modern/css")
    }
    else
    {
        @Styles.Render("~/Content/kendo/css")
        @Styles.Render("~/Content/default/css")
    }

    @Scripts.Render("~/scripts/login/js");

</head>
<body>

    <div id="loading">
        <div class="loadingImg">
        </div>
    </div>

    <div id="root" style="display:none">
        <div id="loginBox">
            <div class="headerlogin">
            </div>

            <div class="title">
                <img src="@Html.BaseUrl()Content/default/images/logo.png" style="width:60px;height:60px" alt="login" />
                @Html.LOBHtmlHelper().Label("lblUserInfomation", "Login information")
            </div>

            <table cellpadding="2" cellspacing="2" style="margin-left:170px">
                <tr>
                    <td style="width: 90px">
                        @Html.LOBHtmlHelper().Label("lblUsername", "User name")
                    </td>
                    <td>
                        @Html.LOBHtmlHelper().Input("txtUsername", InputType.Text, 1, new { @class = "k-textbox", style = "width:250px" })
                    </td>
                </tr>
                <tr>
                    <td style="width: 90px">
                        @Html.LOBHtmlHelper().Label("lblPassword", "Password")
                    </td>
                    <td>
                        @Html.LOBHtmlHelper().Input("txtPassword", InputType.Password, 1, new { @class = "k-textbox", style = "width:250px" })
                    </td>
                </tr>
          
                <tr>
                    <td style="width: 120px">
                        @Html.LOBHtmlHelper().Label("lblLanuage", "Language")
                    </td>
                    <td>
                        @(Html.Kendo().ComboBox()
                          .HtmlAttributes(new { style = "width:250px" })
                          .Name("cboLang")
                          .Filter("contains")
                          .DataTextField("Text")
                          .DataValueField("Value")
                          .BindTo((IList<SelectListItem>)ViewData["cboLg"])
                          .SelectedIndex(0)
                          .Suggest(true)

                        )
                    </td>
                </tr>

                <tr>
                    <td style="width: 90px"></td>
                    <td>
                        <input id="changemetro" type="checkbox" style="display:none" /><label id="lbl" style="display:none">Change metro style</label>
                    </td>
                </tr>

                <tr>
                    <td style="width: 90px">
                        &nbsp;
                    </td>
                    <td>
                        <div style="margin-top:10px">
                            <div class="buttonlogin" style="width:250px">
                                <a href="javascript:void(0)" onclick="Login(false)">
                                    @Html.LOBHtmlHelper().Label("btnLogin", "Login")
                                </a>
                            </div>
                            

                        </div>
                    </td>
                </tr>

            </table>

                
                
        </div>

    </div>
    <div style="color:#333;text-align:center">
        @Html.LOBHtmlHelper().Label("lblLOBHtmlHelper", "Danh hien Copyright @ 2014")
    </div>
    <div id="bannerMetro">
        <div class="buiding"></div>
        <div class="TitleMetro">LV AccNet e</div>
        <div id="metrocompany">
            <div style="width:2px"></div>
            @Html.LOBHtmlHelper().Label("lblLOBHtmlHelper", "Lac Viet Copyright @ 1995- 1999")
        </div>
    </div>

    <script type="text/javascript">
        var timep = 1;

        function changemetro(callback) {
            if ($("#changemetro").is(':checked')) {
                $(".title").animate({
                    'opacity': 0
                }, 0, 'swing', null);

                $(".headerlogin").animate({
                    'opacity': 0
                }, 0, 'swing', null);

                $("#toolbarbottomlogin").animate({
                    'opacity': 0
                }, 0, 'swing', null);

                $("#loginBox").animate({
                    "background": "white",
                    "box-shadow": 0,
                    "-moz-border-radius-topleft": 0,
                    "-moz-border-radius-topright": 0,
                    "-moz-border-radius-bottomleft": 0,
                    "-moz-border-radius-bottomright": 0,
                    "-webkit-border-top-left-radius": 0,
                    "-webkit-border-top-right-radius": 0,
                    "-webkit-border-bottom-left-radius": 0,
                    "-webkit-border-bottom-right-radius": 0,
                    "border-top-left-radius": 50,
                    "border-top-right-radius": 0,
                    "border-bottom-left-radius": 0,
                    "border-bottom-right-radius": 0,
                }, 0, 'swing', function () {
                    $("#loginBox").css("background", "#ffffff");
                    $("#loginBox").css("-moz-box-shadow", "0px 0px 0px #ffffff");
                    $("#loginBox").css("-webkit-box-shadow", "0px 0px 0px #ffffff");
                    $("#loginBox").css("box-shadow", "0px 0px 0px #ffffff");

                    $(".buttonlogin").css("-moz-box-shadow", "0px 0px 0px #ffffff");
                    $(".buttonlogin").css("-webkit-box-shadow", "0px 0px 0px #ffffff");
                    $(".buttonlogin").css("box-shadow", "0px 0px 0px #ffffff");
                    $("#lbl").css("color", "#333");


                    $("#root")
                        .animate({
                            'margin-left': $(window).width() - 100 - $("#root").width(),
                            'margin-top': 20,
                        }, 0, 'swing', function () {
                            $("#bannerMetro")
                                .css("opacity", 0)
                                .css("margin-left", $(window).width() - $("#root").width() - $("#bannerMetro").width())
                                .css("margin-top", 50)
                                .show()
                                .animate({
                                    'margin-left': $(window).width() - $("#root").width() - $("#bannerMetro").width() - 10,
                                    'opacity': 1,
                                }, 0, 'swing', function () { callback() });
                        });

                });


            }
            else {
                $("#bannerMetro")
                               .animate({
                                   'margin-left': $(window).width() - $("#root").width() - $("#bannerMetro").width(),
                                   'opacity': 0,
                               }, 0, 'swing', function () {
                                   $("#root")
                                              .animate({
                                                  'margin-left': ($(window).width() - $("#root").width()) / 2,
                                                  'margin-top': 10,
                                              }, 0, 'swing', function () {
                                                  $(".title").animate({
                                                      'opacity': 1
                                                  }, 0, 'swing', null);

                                                  $(".headerlogin").animate({
                                                      'opacity': 1
                                                  }, 0, 'swing', null);

                                                  $("#toolbarbottomlogin").animate({
                                                      'opacity': 1
                                                  }, 0, 'swing', null);

                                                  $("#loginBox").animate({
                                                      "backgroundColor": "#427ec7",
                                                      "box-shadow": 5,
                                                      "-moz-border-radius-topleft": 5,
                                                      "-moz-border-radius-topright": 5,
                                                      "-moz-border-radius-bottomleft": 5,
                                                      "-moz-border-radius-bottomright": 5,
                                                      "-webkit-border-top-left-radius": 5,
                                                      "-webkit-border-top-right-radius": 5,
                                                      "-webkit-border-bottom-left-radius": 5,
                                                      "-webkit-border-bottom-right-radius": 5,
                                                      "border-top-left-radius": 5,
                                                      "border-top-right-radius": 5,
                                                      "border-bottom-left-radius": 5,
                                                      "border-bottom-right-radius": 5,
                                                  }, 0, 'swing', function () {
                                                      $("#loginBox").css("-moz-box-shadow", "5px 5px 5px #444345");
                                                      $("#loginBox").css("-webkit-box-shadow", "5px 5px 5px #444345");
                                                      $("#loginBox").css("box-shadow", "5px 5px 5px #444345");

                                                      $(".buttonlogin").css("-moz-box-shadow", "2px 2px 4px #333");
                                                      $(".buttonlogin").css("-webkit-box-shadow", "2px 2px 4px #333");
                                                      $(".buttonlogin").css("box-shadow", "2px 2px 4px #333");

                                                      $("#lbl").css("color", "#fff");

                                                      $("#txtUsername").removeAttr("placeholder");
                                                      $("#txtPassword").removeAttr("placeholder");

                                                      $("input[name='cboData_input']").removeAttr("placeholder");
                                                      $("input[name='cboBU_input']").removeAttr("placeholder");
                                                      $("input[name='cboLang_input']").removeAttr("placeholder");


                                                      callback();
                                                  });
                                              });

                               });




            }
        }

        (function ($) {
            $(window).ready(function () {

                var combobox = $("#cboLang").data("kendoComboBox");
                if ($.cookie("lang"))
                    combobox.value($.cookie("lang"));
                else
                    combobox.value("VN");

                // bind to the change event
                if (!IsNull(combobox)) {
                    combobox.bind("change", function (e) {
                        ChangeLanguage(combobox.value());
                    });

                }

                @if (this.Request.QueryString["modern"] == "1")
                 {
                     @: $('#changemetro').attr('checked', true);
                                 }
                else
                {
                @: $('#changemetro').attr('checked', false);
                              }

                $("#changemetro").change(function () {
                    if ($("#changemetro").is(':checked')) {
                        $.cookie("metro", true, { expires: 700, path: "/" });
                        document.location.href = "@Url.Action("Login", "Home", new { modern = "1" })";
                    }
                    else {
                        $.cookie("metro", false, { expires: 700, path: "/" });
                        document.location.href = "@Url.Action("Login", "Home")";
                    }
                });

                ChangeLanguage(combobox.value());

                if ("@ViewBag.Metro" == "1" || $.cookie("metro") == "true") {
                    @if (this.Request.QueryString["modern"] != "1")
                    {
                        @: if (document.location.href.indexOf("?") > 0)
                                                @:      document.location.href = document.location.href + "&modern=1";
                                                @: else
                                                @:      document.location.href = document.location.href + "?modern=1";
                                            @: return;
                                        }
                    $('input:checkbox[id=changemetro]').attr('checked', true);

                    changemetro(function () { $('body').show() });
                }
                else {
                    $("#root").css("margin-top", (($(window).height() - $("#root").height()) / 2)-20);
                    $("#root").css("margin-left", ($(window).width() - $("#root").width()) / 2);
                }



                if ('@ViewBag.logout' == '1') {
                    $.cookie("Remember", 0, { expires: 7, path: "/" });
                    $.cookie("UserName", "", { expires: 7, path: "/" });
                }
                else if ($.cookie("Remember") != null && $.cookie("Remember") != 0) {
                    $("#txtUsername").val($.cookie("UserName"));
                    $.cookie("Remember", $.cookie("Remember") - 1, { expires: 7, path: "/" });
                    //Login(true);
                }
                $("#root").show();
            });

            $(window).load(function () {


                $("#txtUsername").focus();

                var ButtonKeys = { "EnterKey": 13 };
                $(window).keypress(function (e) {
                    if (e.which == ButtonKeys.EnterKey) {
                        Login(false);
                        return false;
                    }
                });
            });
        })(jQuery);

        function ChangeLanguage(l) {
            if (l == "VN") {
                $("#lblUserInfomation")[0].innerHTML = "Thông tin đăng nhập";
                $("#lblUsername")[0].innerHTML = "Người dùng";
                $("#lblPassword")[0].innerHTML = "Mật khẩu";
                $("#lblLanuage")[0].innerHTML = "Ngôn ngữ";
                $("#lbl")[0].innerHTML = "Thay đổi giao diện";
                $("#btnLogin")[0].innerHTML = "Đăng nhập";

                $("#txtUsername").attr("placeholder", "Người dùng").blur();
                $("#txtPassword").attr("placeholder", "Mật khẩu").blur();
                $("input[name='cboLang_input']").attr("placeholder", "Ngôn ngữ").blur();
            }
            else {
                $("#lblUserInfomation")[0].innerHTML = "Login information";
                $("#lblUsername")[0].innerHTML = "User name";
                $("#lblPassword")[0].innerHTML = "Password";
                $("#lblLanuage")[0].innerHTML = "Language";
                $("#lbl")[0].innerHTML = "Change metro style";
                $("#btnLogin")[0].innerHTML = "Login";

                $("#txtUsername").attr("placeholder", "Enter user name").blur();
                $("#txtPassword").attr("placeholder", "Enter your password").blur();
                $("input[name='cboLang_input']").attr("placeholder", "Enter business unit").blur();
            }
        }
        function Login(again) {
            $("#loading").css('display', 'block');
            $("#bannerMetro").fadeOut(500, null);
            $("#loginBox").fadeOut(500, function () {
                var url = '@Url.Action("Login", "Home", new { returnUrl = Request.QueryString["returnUrl"] })';
                var userName = $("#txtUsername").val();
                var password = $("#txtPassword").val();
                var lang = $("#cboLang").data("kendoComboBox").value();

                var metro = $("#changemetro").is(':checked');

                $.post(url, { username: userName, password: password, again: again, PassTime: timep, metro: metro, language: lang }, function (data) {
                    if (data.code != null && data.message != null && data.code != "" && data.message != "") {
                        if (data.code == "0") {
                            window.location = data.message;
                            $.cookie("metro", metro, { expires: 700, path: "/" });
                            $.cookie("lang", lang, { expires: 700, path: "/" });
                        }
                        else {
                            if (data.code == "2")
                                timep = timep + 1;
                            alert(data.message);
                            $("#loading").css('display', 'none');
                            $("#loginBox").fadeIn(500)

                            if (metro) {
                                $("#bannerMetro").fadeIn(500, null);
                            }
                        }
                    }
                });
            });
        }

        function close_window() {
            if (confirm("Do you want to close?")) {
                close();
                document.location = "http://www.LOBHtmlHelper.com.vn/lcmsweb/default.aspx";
            }
        }

    </script>
</body>
</html>
